package com.kfm.goods.task;

import com.kfm.goods.interceptor.IpInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class HelloTask {

    @Autowired
    private IpInterceptor interceptor;

//    @Scheduled(cron = "0 0 0 * * ? ") // 每天凌晨 0 点执行
//    @Scheduled(fixedRate = 5, timeUnit = TimeUnit.SECONDS)
//    public void sayHello(){
//        System.out.println(LocalTime.now() + ": hello");
//    }


//    @Scheduled(cron = "0 0/5 * * * ? *") // 每隔 5 分钟执行一次
    @Scheduled(cron = "0 0 0 * * ? ") // 每天凌晨 0 点执行
    public void removeBlackList(){
        System.out.println(LocalTime.now() + ": removeBlackList");
        interceptor.blackList.clear();
    }
}
